package com.warehouse.module.business.controller.admin.worldCityCode;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.warehouse.framework.common.pojo.CommonResult;
import com.warehouse.framework.common.util.object.BeanUtils;
import com.warehouse.module.business.controller.admin.company.vo.CompanyRespVO;
import com.warehouse.module.business.controller.admin.worldCityCode.vo.WorldCityCodeReqVO;
import com.warehouse.module.business.dal.dataobject.company.CompanyDO;
import com.warehouse.module.business.dal.dataobject.worldCityCode.WorldCityCodeDO;
import com.warehouse.module.business.service.worldCityCode.WorldCityCodeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.security.PermitAll;
import javax.validation.Valid;
import java.util.List;

import static com.warehouse.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 世界城市代码信息")
@RestController
@RequestMapping("/business/citycode")
@Validated
public class WorldCityCodeController {

    @Autowired
    private WorldCityCodeService worldCityCodeService;

    @GetMapping("/list")
    @Operation(summary = "获取世界城市代码列表")
    @PermitAll
    public CommonResult<List<WorldCityCodeDO>> getCompanyList(@Valid WorldCityCodeReqVO pageReqVO) {
        List<WorldCityCodeDO> pageResult = worldCityCodeService.listWordCode(pageReqVO);
        return success(pageResult);
    }

    @GetMapping("/get/{code}")
    public CommonResult<WorldCityCodeDO> getByCode(@PathVariable("code") String code){
        return success(worldCityCodeService.getByCode(code));
    }
}
